﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WeekPlan.aspx.cs" Inherits="ZX.WebApp.TR.WeekPlan" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>周计划周结果</title>
   
    <style type="text/css">
        .style1
        {
            text-align: center;
            font-weight: bold;
            line-height:50px;
            font-size:x-large;
        }
        .style2
        {
            font-size: medium;
            width:12%;
        }
        .style3
        {
            font-size: medium;
            font-weight: bold;
            text-align: center;
        }
        .style4
        {
            text-align: center;
            font-weight: bold;
        }
        .style5
        {
            font-size: medium;
            width: 12%;
            text-align: center;
        }
         .style6
        {
           border-bottom: black 1px solid;
           border-top-style: none;
           border-right-style: none;
           border-left-style: none;
           background-color: white;
           overflow:hidden;
           height: 100%;
           width: 98%;
        }
        .style7
        {
            border-bottom: black 1px solid;
            border-top-style: none;
            border-right-style: none;
            border-left-style: none;
            background-color: white;
            overflow: hidden;
            height: 100%;
            width: 95%;
        }
    </style>
    <script language="javascript" type="text/javascript">
        function AddRow() {
            var tab = $("TabWeekPlan");
            var hdf = $("HdfDiv");
            var rl = tab.rows.length - 2; //插入位置
            var indexid = tab.rows.length - 6 ;

            //添加一行
            var newTr = tab.insertRow(rl);
            var tdr1 = $("TdFirst");
            tdr1.rowSpan = indexid; //合并
            //添加10列
            var newTd0 = newTr.insertCell(0);
            
            var newTd1 = newTr.insertCell(1);
            var newTd2 = newTr.insertCell(2);
            newTd2.colSpan = "2"
            //var newTd3 = newTr.insertCell(3);
            var newTd3 = newTr.insertCell(3);
            var newTd4 = newTr.insertCell(4);
            var newTd5 = newTr.insertCell(5);
            var newTd6 = newTr.insertCell(6);
            var newTd7 = newTr.insertCell(7);
            var newTd8 = newTr.insertCell(8);
            var newTd9 = newTr.insertCell(9);
            var newTd10 = newTr.insertCell(10);
            //填充
            newTd0.innerHTML = '<div style="text-align:center; width:100%">' + indexid + '<input  type="hidden" ID="hd' + indexid + '" /></div>';
            newTd1.innerHTML = '<textarea id="Ta' + indexid + '1" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);"  class="style6" ></textarea>';
            newTd2.innerHTML = '<textarea id="Ta' + indexid + '2" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);"  class="style6" ></textarea>';
            newTd3.innerHTML = '<textarea id="Ta' + indexid + '3" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7" ></textarea>';
            newTd4.innerHTML = '<textarea id="Ta' + indexid + '4" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7" ></textarea>';
            newTd5.innerHTML = '<textarea id="Ta' + indexid + '5" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7" ></textarea>';
            newTd6.innerHTML = '<textarea id="Ta' + indexid + '6" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7" ></textarea>';
            newTd7.innerHTML = '<textarea id="Ta' + indexid + '7" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7" ></textarea>';
            newTd8.innerHTML = '<textarea id="Ta' + indexid + '8" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7" ></textarea>';
            newTd9.innerHTML = '<textarea id="Ta' + indexid + '9" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7" ></textarea>';
            newTd10.innerHTML = '<textarea id="Ta' + indexid + '10" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7" ></textarea>';

            hdf.value = parseInt(hdf.value) + 1;

            //alert(hdf.value);
        }
        function DeleteRow() {
            var tab = $("TabWeekPlan");
            var rl = tab.rows.length - 3; //插入位置
            var tdr1 = $("TdFirst");
            if (tdr1.rowSpan == 1)
                return;
            tdr1.rowSpan = tdr1.rowSpan - 1;
            tab.deleteRow(rl);

            var hdf = $("HdfDiv");
            hdf.value = parseInt(hdf.value) - 1;
            //alert(hdf.value);
        }
        function querystringsave() {
            var hdfclose = $("hdfClose");
            if (hdfclose.value == "") {
                hdfclose.value = queryString("CLOSE");
            }
        }
        //恢复控件及赋值
        function ReviewForm() {
            var HdfDiv = $("HdfDiv");
            var len = parseInt(HdfDiv.value);
            HdfDiv.value = 1;
            if (len > 1) {
                for (var i = 1; i < len; i++) {
                    AddRow();
                }
            }

            //赋值
            var wv = $("hdfWWValue");
            if (wv.value != "") {
                var list = wv.value.split('^');
                for (var i = 0; i < list.length - 1; i++) {
                    var li = list[i].split('|');
                    var hd1 = $("hd" + parseInt(i + 1));
                    var ta1 = $("Ta" + parseInt(i + 1) + "1");
                    var ta2 = $("Ta" + parseInt(i + 1) + "2");
                    var ta3 = $("Ta" + parseInt(i + 1) + "3");
                    var ta4 = $("Ta" + parseInt(i + 1) + "4");
                    var ta5 = $("Ta" + parseInt(i + 1) + "5");
                    var ta6 = $("Ta" + parseInt(i + 1) + "6");
                    var ta7 = $("Ta" + parseInt(i + 1) + "7");
                    var ta8 = $("Ta" + parseInt(i + 1) + "8");
                    var ta9 = $("Ta" + parseInt(i + 1) + "9");
                    var ta10 = $("Ta" + parseInt(i + 1) + "10");
                    hd1.value = li[0];
                    ta1.value = li[1];
                    ta2.value = li[2];
                    ta3.value = li[3];
                    ta4.value = li[4];
                    ta5.value = li[5];
                    ta6.value = li[6];
                    ta7.value = li[7];
                    ta8.value = li[8];
                    ta9.value = li[9];
                    ta10.value = li[10];
                }
            }

        }
        function Save() {
            if (CheckBeforeAdd()) {
                BeforeSave();
                RefreshData();

                var hdfclose = $("hdfClose");
                window.parent.$("#tabs").tabs('close', hdfclose.value);
                
            }
        }

        function RefreshData() {
            if (parent.NeedRefreshPage != null) {
                if (typeof (parent.NeedRefreshPage.LoadData) == "function") {
                    parent.NeedRefreshPage.RefreshData();
                }
            }
        }

        function BeforeSave() {
            var hdf = $("HdfDiv");
            var vx = "";
            for (var i = 1; i <= parseInt(hdf.value); i++) {
                var hd = $("hd" + parseInt(i));
                vx += hd.value + "|";
                for (var j = 1; j <= 10; j++) {
                    var ta = $("Ta" + i + j);
                    vx += replaceAll(replaceAll(ta.value, "^", ""), "|", "") + "|";
                }
                
                vx += "^";
            }

            var wwv = $("hdfWWValue");
            wwv.value = vx;

            //获取计划主表信息
            var hdfmainvalue = $("hdfmainvalue");
//            var hdfChecker = $("hdfChecker");

            var back = ZX.WebApp.TR.WeekPlan.SavePlan(hdfmainvalue.value + "&" + "hdfCheckervalue" + "&" + vx).value;
            if (back == 1) {
                alert("保存成功！");
            }
            else
                alert("保存失败");
        }

        function CheckBeforeAdd() {
            var hdf = $("HdfDiv");
            var len = parseInt(hdf.value);
            if (checkNull(len)) {
                var name = "";
                for (var i = 1; i <= len; i++) {
                    var ta1 = $("Ta" + i + "1");
                    var ta2 = $("Ta" + i + "2");
                    if (ta1.value == "") {
                        alert("请填写[工作内容]");
                        ta1.focus();
                        return false;
                    }
                    else if (ta2.value == "") {
                        alert("请填写[预期结果]");
                        ta2.focus();
                        return false;
                    }
                }
                return true;
            }
            else {
                return false;
            }
        }

        //保存前检查主表信息不能为空
        function checkNull() {
            var hdfmain = $("hdfmainvalue");
            var TaMonthAim = $("TaMonthAim");
            var TaWeekPoint = $("TaWeekPoint");
            if (TaMonthAim.value == "") {
                alert("[本月工作目标] 不能为空");
                TaMonthAim.focus();
                return false;
            }
            else if (TaWeekPoint.value == "") {
                alert("[本周重点工作] 不能为空");
                TaWeekPoint.focus();
                return false;
            }
            else {
                var d = $("ddlWeekNums"); //根据DropDownList的客户端ID获取该控件
                var ddlValue = d.options[d.selectedIndex].value; //获取DropDownList当前选中值
                var st = $("txtMonday");
                var pid = $("hdfpid");
                var et = $("txtFdate");
                var rq = $("TaRequest");
                hdfmain.value =pid.value+"^"+ ddlValue + "^" + st.value + "^" + et.value + "^" + TaMonthAim.value + "^" + TaWeekPoint.value + "^" + rq.value;
                //alert(hdfmain.value + "hdfmain.value");
            }

            return true;
        }
        

        // string:原始字符串
        //substr:子字符串
        //isIgnoreCase:忽略大小写
        function contains(string, substr, isIgnoreCase) {
            if (isIgnoreCase) {
                string = string.toLowerCase();
                substr = substr.toLowerCase();
            }
            var startChar = substr.substring(0, 1);
            var strLen = substr.length;
            for (var j = 0; j < string.length - strLen + 1; j++) {
                if (string.charAt(j) == startChar)  //如果匹配起始字符,开始查找
                {
                    if (string.substring(j, j + strLen) == substr)  //如果从j开始的字符与str匹配，那ok
                    {
                        return true;
                    }
                }
            }
            return false;
        }
        //替换所有
        //s1原始字符串
        //s2子字符串
        //s3子字符串要替换成的值
        function replaceAll(s1, s2, s3) {
            var r = new RegExp(s2.replace(/([\(\)\[\]\{\}\^\$\+\-\*\?\.\"\'\|\/\\])/g, "\\$1"), "ig");
            return s1.replace(r, s3);
        }
        function $(id) { return document.getElementById(id) }

        //lastest:
        var queryStrings = function () {
            var params = document.location.search, reg = /(?:^\?|&)(.*?)=(.*?)(?=&|$)/g, temp, args = {};
            while ((temp = reg.exec(params)) != null) args[temp[1]] = decodeURIComponent(temp[2]);
            return args;
        };
        //只取一个URL参数：
        var queryString = function (key) {
            return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
        }

        //限制输入字数
        function MaxText(obj,max) {
            if (obj.value.length > max) {
                alert("最多可输入"+max+"个字");
                obj.value = obj.value.substr(0,max);
            }
        }
    </script>
</head>
<body onload="querystringsave();">
    <form id="form1" runat="server">
    <asp:HiddenField ID="hdfpid" runat="server" />
    <asp:HiddenField ID="HdfDiv" runat="server" Value="1" />
    <asp:HiddenField ID="hdfWWValue" runat="server" />
    <asp:HiddenField ID="hdfChecker" runat="server" />
    <asp:HiddenField ID="hdfmainvalue" runat="server" />
    <asp:HiddenField ID="hdfClose" runat="server" Value="" />
        <table id="TabWeekPlan" border="1" cellpadding="0" cellspacing="0" style="
            width: 100%; height:100%" bordercolor="#FFFFFF" bordercolorlight="#000000" bgcolor="#F2F2F2">
            <tr  style=" visibility:visible;">
                <td colspan="13" >
                </td>
            </tr>
            <tr>
                <td colspan="5" class="style1">
                    <asp:Label ID="LabName" runat="server" ></asp:Label>
                    — 周计划
                </td>
                <td class="style1">
                    周次
                </td>
                <td colspan="7">
                    <asp:DropDownList ID="ddlWeekNums" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlWeekNums_OnSelectedIndexChanged">
                        <asp:ListItem Value="1">1</asp:ListItem>
                        <asp:ListItem Value="2">2</asp:ListItem>
                        <asp:ListItem Value="3">3</asp:ListItem>
                        <asp:ListItem Value="4">4</asp:ListItem>
                        <asp:ListItem Value="5">5</asp:ListItem>
                        <asp:ListItem Value="6">6</asp:ListItem>
                        <asp:ListItem Value="7">7</asp:ListItem>
                        <asp:ListItem Value="8">8</asp:ListItem>
                        <asp:ListItem Value="9">9</asp:ListItem>
                        <asp:ListItem Value="10">10</asp:ListItem>
                        <asp:ListItem Value="11">11</asp:ListItem>
                        <asp:ListItem Value="12">12</asp:ListItem>
                        <asp:ListItem Value="13">13</asp:ListItem>
                        <asp:ListItem Value="14">14</asp:ListItem>
                        <asp:ListItem Value="15">15</asp:ListItem>
                        <asp:ListItem Value="16">16</asp:ListItem>
                        <asp:ListItem Value="17">17</asp:ListItem>
                        <asp:ListItem Value="18">18</asp:ListItem>
                        <asp:ListItem Value="19">19</asp:ListItem>
                        <asp:ListItem Value="20">20</asp:ListItem>
                        <asp:ListItem Value="21">21</asp:ListItem>
                        <asp:ListItem Value="22">22</asp:ListItem>
                        <asp:ListItem Value="23">23</asp:ListItem>
                        <asp:ListItem Value="24">24</asp:ListItem>
                        <asp:ListItem Value="25">25</asp:ListItem>
                        <asp:ListItem Value="26">26</asp:ListItem>
                        <asp:ListItem Value="27">27</asp:ListItem>
                        <asp:ListItem Value="28">28</asp:ListItem>
                        <asp:ListItem Value="29">29</asp:ListItem>
                        <asp:ListItem Value="30">30</asp:ListItem>
                        <asp:ListItem Value="31">31</asp:ListItem>
                        <asp:ListItem Value="32">32</asp:ListItem>
                        <asp:ListItem Value="33">33</asp:ListItem>
                        <asp:ListItem Value="34">34</asp:ListItem>
                        <asp:ListItem Value="35">35</asp:ListItem>
                        <asp:ListItem Value="36">36</asp:ListItem>
                        <asp:ListItem Value="37">37</asp:ListItem>
                        <asp:ListItem Value="38">38</asp:ListItem>
                        <asp:ListItem Value="39">39</asp:ListItem>
                        <asp:ListItem Value="40">40</asp:ListItem>
                        <asp:ListItem Value="41">41</asp:ListItem>
                        <asp:ListItem Value="42">42</asp:ListItem>
                        <asp:ListItem Value="43">43</asp:ListItem>
                        <asp:ListItem Value="44">44</asp:ListItem>
                        <asp:ListItem Value="45">45</asp:ListItem>
                        <asp:ListItem Value="46">46</asp:ListItem>
                        <asp:ListItem Value="47">47</asp:ListItem>
                        <asp:ListItem Value="48">48</asp:ListItem>
                        <asp:ListItem Value="49">49</asp:ListItem>
                        <asp:ListItem Value="50">50</asp:ListItem>
                        <asp:ListItem Value="51">51</asp:ListItem>
                        <asp:ListItem Value="52">52</asp:ListItem>
                        <asp:ListItem Value="53">53</asp:ListItem>
                    </asp:DropDownList>
                    （<asp:TextBox ID="txtMonday" Width="30%" Enabled="false"  runat="server"></asp:TextBox>-<asp:TextBox
                        ID="txtFdate" Width="30%" runat="server"  Enabled="false"></asp:TextBox>）
                </td>
            </tr>
            <tr class="style2">
                <td class="style4">
                    本月工作目标
                </td>
                <td colspan="3">
                    <textarea id="TaMonthAim" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" runat="server" class="style6"></textarea>
                </td>
                <td colspan="2" class="style4">
                    本周重点工作
                </td>
                <td colspan="7">
                    <textarea id="TaWeekPoint" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" runat="server" class="style6"></textarea>
                </td>
            </tr>
            <tr>
                <td rowspan="2" class="style3">
                    工作性质
                </td>
                <td rowspan="2" class="style4">
                    <b>序号
                </td>
                <td rowspan="2" class="style4">
                    工作内容
                </td>
                <td rowspan="2" colspan="2" class="style4">
                    预期结果
                </td>
                <%--<td rowspan="2" class="style4">
                    检查人
                </td>--%>
                <td colspan="7" class="style4">
                    阶段性结果
                </td>
                <td rowspan="2" class="style4">
                    自罚承诺
                </td>
            </tr>
            <tr>
                <td class="style4">
                    <b>周一
                </td>
                <td class="style4">
                    周二
                </td>
                <td class="style4">
                    周三
                </td>
                <td class="style4">
                    周四
                </td>
                <td class="style4">
                    周五
                </td>
                <td class="style4">
                    周六
                </td>
                <td class="style4">
                    周日
                </td>
            </tr>
            <tr>
                <td id="TdFirst" rowspan="1" class="style5">
                    本周重要工作<br />
                    (按重要性排序)
                </td>
                <td style="width: 2%; text-align: center;">
                    1<asp:HiddenField runat="server" ID="hd1" />
                </td>
                <td style="width: 20%;">
                    <textarea id="Ta11" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style6" ></textarea>
                </td>
                <td colspan="2" style="width: 18%;">
                    <textarea id="Ta12" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style6"></textarea>
                </td>
                <td style="width: 5%;">
                    <textarea id="Ta13" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7"></textarea>
                </td>
                <td style="width: 5%;">
                    <textarea id="Ta14" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7"></textarea>
                </td>
                <td style="width: 5%;">
                    <textarea id="Ta15" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7"></textarea>
                </td>
                <td style="width: 5%;">
                    <textarea id="Ta16" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7"></textarea>
                </td>
                <td style="width: 5%;">
                    <textarea id="Ta17" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7"></textarea>
                </td>
                <td style="width: 5%;">
                    <textarea id="Ta18" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7"></textarea>
                </td>
                <td style="width: 5%;">
                    <textarea id="Ta19" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7"></textarea>
                </td>
                <td style="width: 9%;">
                    <textarea id="Ta110" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" class="style7"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="style5">
                    所需资源支持
                </td>
                <td colspan="10">
                    <textarea id="TaRequest" onkeypress="return MaxText(this,200);" onmouseover="return MaxText(this,200);" runat="server" class="style6"></textarea>
                </td>
                <td>
                    <img src="../Images/Peixun/add.gif" title="添加工作项" style="float: left; margin-left: 5px;
                        cursor: pointer" alt="添加行" onclick="return AddRow();" />
                    <img src="../Images/Peixun/cancel.gif" title="删除工作项" style="float: right; margin-right: 6px;
                        cursor: pointer" alt="删除行" onclick="return DeleteRow();" />
                </td>
            </tr>
            <tr>
                <td colspan="12">
                    1、“主要工作内容”栏可以根据部门业务需要合并成一栏或拆分成两栏；<br />
                    2、“阶段性结果”栏可根据实际业务情况合并描述；<br />
                    3、“所需资源支持”既可以是针对公司，也可以是针对其他部门提出的。
                </td>
                <td align="center">
                    <img src="../Images/Peixun/save.bmp" title="保存" style="float: left; margin-left: 10px;
                        cursor: pointer" alt="保存" onclick="return Save();" />
                </td>
            </tr>
        </table>
    
    </form>
</body>
</html>
